interface AppProps {
  search: String;
  lang: String;
  isLoading: boolean;
  menus: Array<any>;
  footer: WebConfigProp | undefined;
}
export const useApp = () => {
  const app = useState<AppProps>("app", () => {
    return {
      search: "",
      lang: "zh",
      isLoading: true,
      menus: [],
      footer: undefined,
    };
  });
  const changeSearch = (val: String) => {
    app.value.search = val;
    // console.log(val);
  };
  const toggleLoading = (val: boolean) => {
    app.value.isLoading = val;
  };

  const setMenus = (list: any) => {
    app.value.menus = list;
  };

  const setFooter = (data: any) => {
    app.value.footer = data;
  };

  const toggleLang = (val: String) => {
    app.value.lang = val;
    // console.log(val);
  };

  return {
    app,
    toggleLoading,
    changeSearch,
    toggleLang,
    setMenus,
    setFooter,
  };
};
